package com.yang.jxj.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yang.jxj.entity.Test;
import com.yang.jxj.service.ITestService;
import com.yang.jxj.service.impl.TestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yang
 * @since 2024-06-20
 */
@RestController
@RequestMapping("/api/test")


public class TestController {

    @Autowired
    private ITestService user1;
    @Autowired
    private TestServiceImpl user2;

    @GetMapping("/list")
    public List<Test> list() {
        return this.user1.list();
    }
    @GetMapping("/show")
    public boolean delete() {
         return user2.removeById(1);
    }
    @GetMapping("/page")
    public IPage<Test> findPage(@RequestParam Integer pageNum,
                                @RequestParam Integer pageSize){
        IPage<Test> page = new Page<>(pageNum, pageSize);
        QueryWrapper<Test> Wrapper = new QueryWrapper<>();
        return user2.page(page);
    }
    @GetMapping("/test")
    public HashMap<String,Object> test(){
        HashMap<String,Object> map = new HashMap<>();
        map.put("user1",user1.list());
        String abc = "{'a':'a','b':'b','c':'c'}";
        map.put("user2", abc);
        return map;
    }


}
